package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzZaixian;
import com.ruoyi.system.service.IDzZaixianService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 在线记录Controller
 * 
 * @author ruoyi
 * @date 2022-09-28
 */
@RestController
@RequestMapping("/system/zaixian")
public class DzZaixianController extends BaseController
{
    @Autowired
    private IDzZaixianService dzZaixianService;

    /**
     * 查询在线记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:zaixian:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzZaixian dzZaixian)
    {
        startPage();
        List<DzZaixian> list = dzZaixianService.selectDzZaixianList(dzZaixian);
        return getDataTable(list);
    }

    /**
     * 导出在线记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:zaixian:export')")
    @Log(title = "在线记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzZaixian dzZaixian)
    {
        List<DzZaixian> list = dzZaixianService.selectDzZaixianList(dzZaixian);
        ExcelUtil<DzZaixian> util = new ExcelUtil<DzZaixian>(DzZaixian.class);
        util.exportExcel(response, list, "在线记录数据");
    }

    /**
     * 获取在线记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:zaixian:query')")
    @GetMapping(value = "/{zxId}")
    public AjaxResult getInfo(@PathVariable("zxId") Long zxId)
    {
        return AjaxResult.success(dzZaixianService.selectDzZaixianByZxId(zxId));
    }

    /**
     * 新增在线记录
     */
    @PreAuthorize("@ss.hasPermi('system:zaixian:add')")
    @Log(title = "在线记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzZaixian dzZaixian)
    {
        return toAjax(dzZaixianService.insertDzZaixian(dzZaixian));
    }

    /**
     * 修改在线记录
     */
    @PreAuthorize("@ss.hasPermi('system:zaixian:edit')")
    @Log(title = "在线记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzZaixian dzZaixian)
    {
        return toAjax(dzZaixianService.updateDzZaixian(dzZaixian));
    }

    /**
     * 删除在线记录
     */
    @PreAuthorize("@ss.hasPermi('system:zaixian:remove')")
    @Log(title = "在线记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zxIds}")
    public AjaxResult remove(@PathVariable Long[] zxIds)
    {
        return toAjax(dzZaixianService.deleteDzZaixianByZxIds(zxIds));
    }
}
